package com.esri.core.tasks.geodatabase;

import com.esri.core.internal.tasks.f;
import com.esri.core.internal.util.d;
import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class SyncGeodatabaseParameters extends f {
    private static final String ASYNC_FIELDNAME = "async";
    private static final String DATA_FORMAT_FIELDNAME = "dataFormat";
    private static final String EDITS_UPLOAD_FORMAT_FIELDNAME = "editsUploadFormat";
    private static final String EDITS_UPLOAD_ID_FIELDNAME = "editsUploadId";
    private static final String REPLICA_ID_FIELDNAME = "replicaID";
    private static final String REPLICA_SERVER_GEN_FIELDNAME = "replicaServerGen";
    private static final String RETURN_ATTACHMENTS_DATA_BY_URL_FIELD = "returnAttachmentDatabyURL";
    private static final String RETURN_IDS_FOR_ADDS_FIELD = "returnIdsForAdds";
    private static final String SYNC_DIRECTION_FIELDNAME = "syncDirection";
    private static final String SYNC_GEODATABASE_INFO_FIELDNAME = "syncGeodatabaseInfo";
    private static final String SYNC_LAYERS_FIELDNAME = "syncLayers";
    private static final String SYNC_MODEL_FIELDNAME = "syncModel";
    private static final long serialVersionUID = 1;
    private SyncGeodatabaseInfo _syncInfo = new SyncGeodatabaseInfo();
    private String _uploadId;

    @Override // com.esri.core.internal.tasks.f
    public boolean validate() {
        return true;
    }

    private SyncGeodatabaseParameters() {
    }

    public String getGeodatabaseId() {
        return this._syncInfo.getGeodatabaseId();
    }

    public void setGeodatabaseId(String str) {
        this._syncInfo.setGeodatabaseId(str);
    }

    public SyncModel getSyncModel() {
        return this._syncInfo.getSyncModel();
    }

    public long getGeodatabaseServerGen() {
        return this._syncInfo.getGeodatabaseServerGen();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void setGeodatabaseServerGen(long j) {
        this._syncInfo.setGeodatabaseServerGen(j);
    }

    public SyncDirection getSyncDirection() {
        return this._syncInfo.getSyncDirection();
    }

    public void setSyncDirection(SyncDirection syncDirection) {
        this._syncInfo.setSyncDirection(syncDirection);
    }

    public LayerSyncInfos getSyncLayers() {
        return this._syncInfo.getSyncLayers();
    }

    public void setSyncLayers(LayerSyncInfos layerSyncInfos) {
        this._syncInfo.setSyncLayers(layerSyncInfos);
    }

    public String getUploadId() {
        return this._uploadId;
    }

    public void setUploadId(String str) {
        this._uploadId = str;
    }

    @Override // com.esri.core.internal.tasks.f
    public Map<String, String> generateRequestParams() throws Exception {
        HashMap hashMap = new HashMap();
        hashMap.put("f", "json");
        hashMap.put(REPLICA_ID_FIELDNAME, getGeodatabaseId());
        if (getSyncModel() == SyncModel.GEODATABASE) {
            hashMap.put(REPLICA_SERVER_GEN_FIELDNAME, new Long(getGeodatabaseServerGen()).toString());
        }
        hashMap.put(ASYNC_FIELDNAME, "true");
        hashMap.put(SYNC_DIRECTION_FIELDNAME, getSyncDirection().getValue());
        LayerSyncInfos syncLayers = getSyncLayers();
        if (syncLayers != null) {
            hashMap.put(SYNC_LAYERS_FIELDNAME, syncLayers.toJsonForRest());
        }
        String str = this._uploadId;
        if (str != null && str.length() > 0) {
            hashMap.put(EDITS_UPLOAD_ID_FIELDNAME, this._uploadId);
        }
        hashMap.put(RETURN_ATTACHMENTS_DATA_BY_URL_FIELD, "false");
        hashMap.put(RETURN_IDS_FOR_ADDS_FIELD, "false");
        hashMap.put(EDITS_UPLOAD_FORMAT_FIELDNAME, "sqlite");
        hashMap.put(DATA_FORMAT_FIELDNAME, "sqlite");
        return hashMap;
    }

    public static SyncGeodatabaseParameters fromJson(JsonParser jsonParser) throws Exception {
        if (d.c(jsonParser)) {
            SyncGeodatabaseParameters syncGeodatabaseParameters = new SyncGeodatabaseParameters();
            try {
                syncGeodatabaseParameters._syncInfo.initFromJson(jsonParser);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return syncGeodatabaseParameters;
        }
        return null;
    }

    public String toJson(boolean z) throws IOException {
        return this._syncInfo.toJson(z);
    }

    public int hashCode() {
        SyncGeodatabaseInfo syncGeodatabaseInfo = this._syncInfo;
        return 31 + (syncGeodatabaseInfo == null ? 0 : syncGeodatabaseInfo.hashCode());
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            SyncGeodatabaseParameters syncGeodatabaseParameters = (SyncGeodatabaseParameters) obj;
            SyncGeodatabaseInfo syncGeodatabaseInfo = this._syncInfo;
            if (syncGeodatabaseInfo == null) {
                if (syncGeodatabaseParameters._syncInfo != null) {
                    return false;
                }
            } else if (!syncGeodatabaseInfo.equals(syncGeodatabaseParameters._syncInfo)) {
                return false;
            }
            String str = this._uploadId;
            if (str == null) {
                if (syncGeodatabaseParameters._uploadId != null) {
                    return false;
                }
            } else if (!str.equals(syncGeodatabaseParameters._uploadId)) {
                return false;
            }
            return true;
        }
        return false;
    }

    public String toString() {
        return "SyncGeodatabaseParameters [_uploadId=" + this._uploadId + ", _syncInfo=" + this._syncInfo + "]";
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public class SyncGeodatabaseInfo {
        private static final String REF_LAYER_SERVER_GENS_FIELDNAME = "refLayerServerGens";
        private static final String REF_REPLICA_ID_FIELDNAME = "refReplicaId";
        private static final String REF_REPLICA_SERVER_GEN_FIELDNAME = "refReplicaServerGen";
        private static final String REPLICA_CLIENT_GEN_FIELDNAME = "replicaClientGen";
        private long _replicaClientGen;
        private String _replicaId;
        private long _replicaServerGen;
        private SyncDirection _syncDirection;
        private LayerSyncInfos _syncLayers;
        private SyncModel _syncModel;

        private SyncGeodatabaseInfo() {
        }

        public String getGeodatabaseId() {
            return this._replicaId;
        }

        public void setGeodatabaseId(String str) {
            this._replicaId = str;
        }

        public long getGeodatabaseServerGen() {
            return this._replicaServerGen;
        }

        public void setGeodatabaseServerGen(long j) {
            this._replicaServerGen = j;
        }

        public SyncDirection getSyncDirection() {
            return this._syncDirection;
        }

        public void setSyncDirection(SyncDirection syncDirection) {
            this._syncDirection = syncDirection;
        }

        public LayerSyncInfos getSyncLayers() {
            return this._syncLayers;
        }

        public void setSyncLayers(LayerSyncInfos layerSyncInfos) {
            this._syncLayers = layerSyncInfos;
        }

        public SyncModel getSyncModel() {
            return this._syncModel;
        }

        public void initFromJson(JsonParser jsonParser) throws Exception {
            if (d.c(jsonParser)) {
                while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                    String currentName = jsonParser.getCurrentName();
                    jsonParser.nextToken();
                    if (SyncGeodatabaseParameters.REPLICA_ID_FIELDNAME.equals(currentName)) {
                        this._replicaId = jsonParser.getText();
                    } else if (SyncGeodatabaseParameters.REPLICA_SERVER_GEN_FIELDNAME.equals(currentName)) {
                        this._replicaServerGen = jsonParser.getLongValue();
                    } else if (REPLICA_CLIENT_GEN_FIELDNAME.equals(currentName)) {
                        this._replicaClientGen = jsonParser.getLongValue();
                    } else if (SyncGeodatabaseParameters.SYNC_DIRECTION_FIELDNAME.equals(currentName)) {
                        this._syncDirection = SyncDirection.fromString(jsonParser.getText());
                    } else if (SyncGeodatabaseParameters.SYNC_MODEL_FIELDNAME.equals(currentName)) {
                        this._syncModel = SyncModel.fromString(jsonParser.getText());
                    } else if (SyncGeodatabaseParameters.SYNC_LAYERS_FIELDNAME.equals(currentName)) {
                        this._syncLayers = LayerSyncInfos.fromJson(jsonParser);
                    } else {
                        jsonParser.skipChildren();
                    }
                }
            }
        }

        public String toJson(boolean z) throws IOException {
            StringWriter stringWriter = new StringWriter();
            JsonGenerator a = d.a(stringWriter);
            a.writeStartObject();
            if (z) {
                a.writeStringField(REF_REPLICA_ID_FIELDNAME, this._replicaId);
                if (SyncModel.GEODATABASE == this._syncModel) {
                    a.writeNumberField(REF_REPLICA_SERVER_GEN_FIELDNAME, this._replicaServerGen);
                } else {
                    a.writeFieldName(REF_LAYER_SERVER_GENS_FIELDNAME);
                    a.writeRawValue(this._syncLayers.toJsonForRest());
                }
            } else {
                a.writeStringField(SyncGeodatabaseParameters.REPLICA_ID_FIELDNAME, this._replicaId);
                a.writeStringField(SyncGeodatabaseParameters.SYNC_MODEL_FIELDNAME, this._syncModel.getValue());
                a.writeStringField(SyncGeodatabaseParameters.SYNC_DIRECTION_FIELDNAME, this._syncDirection.getValue());
                if (SyncModel.GEODATABASE == this._syncModel) {
                    a.writeNumberField(SyncGeodatabaseParameters.REPLICA_SERVER_GEN_FIELDNAME, this._replicaServerGen);
                    a.writeNumberField(REPLICA_CLIENT_GEN_FIELDNAME, this._replicaClientGen);
                } else {
                    a.writeFieldName(SyncGeodatabaseParameters.SYNC_LAYERS_FIELDNAME);
                    a.writeRawValue(this._syncLayers.toJson());
                }
            }
            a.writeEndObject();
            a.close();
            return stringWriter.toString();
        }

        public int hashCode() {
            long j = this._replicaClientGen;
            int i = (((int) (j ^ (j >>> 32))) + 31) * 31;
            String str = this._replicaId;
            int hashCode = str == null ? 0 : str.hashCode();
            long j2 = this._replicaServerGen;
            int i2 = (((i + hashCode) * 31) + ((int) ((j2 >>> 32) ^ j2))) * 31;
            SyncDirection syncDirection = this._syncDirection;
            int hashCode2 = (i2 + (syncDirection == null ? 0 : syncDirection.hashCode())) * 31;
            LayerSyncInfos layerSyncInfos = this._syncLayers;
            int hashCode3 = (hashCode2 + (layerSyncInfos == null ? 0 : layerSyncInfos.hashCode())) * 31;
            SyncModel syncModel = this._syncModel;
            return hashCode3 + (syncModel != null ? syncModel.hashCode() : 0);
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj != null && getClass() == obj.getClass()) {
                SyncGeodatabaseInfo syncGeodatabaseInfo = (SyncGeodatabaseInfo) obj;
                if (this._replicaClientGen != syncGeodatabaseInfo._replicaClientGen) {
                    return false;
                }
                String str = this._replicaId;
                if (str == null) {
                    if (syncGeodatabaseInfo._replicaId != null) {
                        return false;
                    }
                } else if (!str.equals(syncGeodatabaseInfo._replicaId)) {
                    return false;
                }
                if (this._replicaServerGen == syncGeodatabaseInfo._replicaServerGen && this._syncDirection == syncGeodatabaseInfo._syncDirection) {
                    LayerSyncInfos layerSyncInfos = this._syncLayers;
                    if (layerSyncInfos == null) {
                        if (syncGeodatabaseInfo._syncLayers != null) {
                            return false;
                        }
                    } else if (!layerSyncInfos.equals(syncGeodatabaseInfo._syncLayers)) {
                        return false;
                    }
                    return this._syncModel == syncGeodatabaseInfo._syncModel;
                }
                return false;
            }
            return false;
        }

        public String toString() {
            return "SyncGeodatabaseInfo [_replicaId=" + this._replicaId + ", _replicaServerGen=" + this._replicaServerGen + ", _replicaClientGen=" + this._replicaClientGen + ", _syncDirection=" + this._syncDirection + ", _syncLayers=" + this._syncLayers + ", _syncModel=" + this._syncModel + "]";
        }
    }
}
